package com.zfast.forge.wechat.config;


import com.zfast.forge.wechat.constant.Contants;
import com.zfast.forge.wechat.pojo.bo.App;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;


/**
 * @Description: 小程序
 * @author zgn
 * @date 2019年6月17日
 */
@Data
@Builder
@NoArgsConstructor
public class WxConfig {
	private static HashMap<String, String> wxMap = new HashMap<String, String>();
	private static HashMap<String, Object> appsMap= new HashMap<String, Object>();
	private String storeId;

	public WxConfig(String storeId) {
		this.storeId=storeId;
		initApps();
	}

    private void initApps() {
		App app=App.builder()
				.appId("wx95985f36ad38199d").appSecret("f1750b66926768c87b5c50121096eb5a").appName("??")
				.smsMchId("17").smsAppSecret("5868c0dfb097439489e3c6cbb07349e6")
				.build();
    	appsMap.put("A001001", app);
    }

	public App getApps(){
		if(appsMap.get(this.storeId)!=null) {
			return (App) appsMap.get(this.storeId);
		}else {
			App app=App.builder()
					.appId("").appSecret("").appName("").smsMchId("").smsAppSecret("")
					.build();
			return app;
		}
	}

	public String getGoback() {
		return Contants.DOMAIN_URL;
	}

	public String getAppId() {
		return getApps().getAppId();
	}

	public String getAppSecret() {
		return getApps().getAppSecret();
	}

	public String getSmsUrl() {
		return Contants.DOMAIN_URL_SENDMSG;
	}

	public String getSmsMchId() {
		return getApps().getSmsMchId();
	}

	public String getSmsAppSecret() {
		return getApps().getSmsAppSecret();
	}

	public String Code2Session() {
		return "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
	}

	public String getAccessToken() {
		return "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
	}

}
